<template>
  <div class="home">
    <el-container>
      <el-header class="el-header">
        <el-row :gutter="20">
          <el-col :span="4"><img class="logo" src="../assets/logo.svg" /></el-col>
          <el-col :span="16"><h2 class="h2">后台管理系统</h2></el-col>
          <el-col :span="4"><el_button @click="delToken" class="exit">退出登录</el_button></el-col>
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            active-text-color="#ffd04b"
            background-color="#545c64"
            class="el-menu-vertical-demo"
            :default-active="route.path"
            text-color="#fff"
            router
          >
            <el-menu-item :index="item.path" v-for="item in list" :key="item.path">
              <span>{{item.meta.title}}</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <!-- 设置路由出口 -->
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import {useRouter,useRoute} from 'vue-router'

const router = useRouter();
const route = useRoute();

const list = router.getRoutes().filter(v => v.meta.isShow)

const delToken = () => {
  localStorage.removeItem('token')
  router.push('/login')
}

</script>

<style lang="scss" scoped>
.home {
}
.el-header {
  height: 80px;
  background-color: gray;
  .logo {
    height: 80px;
  }
  .h2,
  .exit {
    text-align: center;
    height: 80px;
    line-height: 80px;
    color: #fff;
  }
}
.el-aside {
  .el-menu {
    height: calc(100vh - 80px);
  }
}
</style>
